﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TeacherHelp.Public
{
    /// <summary>
    /// 配置文件帮助类
    /// </summary>
    public static class ConfigHelper
    {
        /// <summary>
        /// SQL Server 连接字符串
        /// </summary>
        public static string strConn
        {
            get
            {
                return ConfigurationManager.ConnectionStrings["strConn"].ConnectionString ?? throw new Exception("未获取到连接字符串strConn！");
            }
        }

        /// <summary>
        /// 考试时间 单位秒
        /// </summary>
        public static int testTime
        {
            get
            {
                string value = ConfigurationManager.ConnectionStrings["testTime"].ConnectionString;
                int result;
                if (!int.TryParse(value, out result))
                {
                    return 60 * 60;
                }
                else
                {
                    if (result <= 0)
                    {
                        return 60 * 60;
                    }
                    return result;
                }
            }
        }

        /// <summary>
        /// 是否生成快捷方式 true||false
        /// </summary>
        public static bool isBuilderShortcut
        {

            get
            {
                string value = ConfigurationManager.ConnectionStrings["isBuilderShortcut"].ConnectionString;
                bool result;
                if (!bool.TryParse(value, out result))
                {
                    return false;
                }
                else
                {
                    return result;
                }
            }
        }
    }
}
